type Key = string | number | undefined
//元素节点的属性
export interface VNodeData {
    class?: Array<string> | string//class类名
    style?: Object //css样式
    key?: Key//元素的唯一标识
    id?: string  //元素id
    [key: string]: any //....等等还有很多，就不列举了
}

//虚拟dom对象的表示
export interface VNode {
    //元素type
    sel: string | undefined,
    //真实dom
    ele: Element | undefined,
    //是否挂载
    mount: Boolean | undefined,
    //元素属性
    data: VNodeData | undefined
    //元素的节点
    children: Array<VNode | string> | undefined
    //元素的文本节点
    text: string | undefined
    //元素的唯一标识
    key: Key
}

//整理虚拟dom对象
export function vnode(sel: string | undefined,
    data: any | undefined,
    children: Array<VNode | string> | undefined,
    text: string | undefined,
    ele: Element | undefined,
    mount: Boolean | undefined): VNode {
    const key = data === undefined ? undefined : data.key
    return { sel, data, ele, mount, children, text, key }
}